/**
 * 
 */
package com.orisper.omp.modules.type;

import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.orisper.dao.Bm_typeDao;
import com.orisper.dao.Bm_typePO;

import aos.framework.core.typewrap.Dto;
import aos.framework.core.utils.AOSJson;
import aos.framework.web.router.HttpModel;
import aos.system.common.service.AOSBaseService;

/**
 * @author acer
 *
 */
@Service
public class TypeService extends AOSBaseService{
	@Autowired
	Bm_typeDao bm_typeDao;
	
	
	/**
	 * 查询分类管理列表
	 * 
	 * @param httpModel
	 */
	public void typeList(HttpModel httpModel) {
		Dto inDto = httpModel.getInDto();
		List<Dto> list = sqlDao.list("Type.listPage",inDto);
		httpModel.setOutMsg(AOSJson.toGridJson(list, inDto.getPageTotal()));
	}

	
	/**
	 * 查询
	 * 
	 * @param httpModel
	 */
	public void getType(HttpModel httpModel) {
		Dto inDto = httpModel.getInDto();
		Bm_typePO bm_typePO = bm_typeDao.selectByKey(inDto.getInteger("id"));
		httpModel.setOutMsg(AOSJson.toJson(bm_typePO));
	}
	
	/**
	 * 修改分
	 * 
	 * @param httpModel
	 */
	public void updateType(HttpModel httpModel) {
		Dto inDto = httpModel.getInDto();
		Bm_typePO bm_typePO = new Bm_typePO();
		bm_typePO.copyProperties(inDto);
		bm_typePO.setModify_date(new Date());
		bm_typeDao.updateByKey(bm_typePO);
		httpModel.setOutMsg("修改成功");
	}
	
	/**
	 * 添加
	 * @param httpModel
	 */
	public void addType(HttpModel httpModel) {
		Dto inDto = httpModel.getInDto();
		Bm_typePO bm_typePO = new Bm_typePO();
		bm_typePO.copyProperties(inDto);
		bm_typePO.setCreate_date(new Date());
		bm_typeDao.insert(bm_typePO);
		httpModel.setOutMsg("添加成功");
	}

	
	/**
	 * 删除
	 * 
	 * @param httpModel
	 * @return
	 */
	public void deleteType(HttpModel httpModel) {
		Dto inDto = httpModel.getInDto();
		Integer res=bm_typeDao.deleteByKey(inDto.getInteger("id"));
		String result=res>0?"删除成功":"删除失败";
		httpModel.setOutMsg(result);
	}
}
